<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %>
<%@ page import="org.jwos.plugin.file.domain.*" %>
<%@ page import="org.jwos.plugin.file.web.*" %>
<%@ page import="org.jwos.platform.ajax.*" %>
<%@ page import="org.jwos.platform.domain.*" %>
<%@ page import="org.jwos.platform.service.*" %>
<%@ page import="org.jwos.plugin.file.service.*" %>
<%
String sessionId = request.getParameter("sessionId");
SessionManager sessionManager = (SessionManager)ServiceFactory.getService(request.getSession().getServletContext(),"sessionManager");
Message message = null;
if(sessionId!=null) {
	User user = sessionManager.getUserBySessionId(sessionId);
	if(session.getAttribute("message_"+user.getLocale())!=null) {
		message = (Message)session.getAttribute("message_"+user.getLocale());
	} else {
		message = new Message(user.getLocale());
		message.setClassLoader(this.getClass().getClassLoader());
		session.setAttribute("message_"+user.getLocale(),message);
	}
}

String folderId = request.getParameter("FolderID");
String fileId = request.getParameter("FileID");
String files = request.getParameter("Files");
String folders = request.getParameter("Folders");
String[] fileIds = null;
if(files!=null && files.length()>0) {
	fileIds = files.split(",");
}
String[] folderIds = null;
if(folders!=null && folders.length()>0) {
	folderIds = folders.split(",");
}

FileInfo info = new FileInfo();
FileManager service = (FileManager)ServiceFactory.getService(request.getSession().getServletContext(),"fileManager");
boolean isFile = false;
boolean isFolder = false;
boolean isMultiple = false;
if(fileId!=null) {
	isFile = true;
	info = service.getFileProperties(sessionId,fileId);
} else if(folderId!=null) {
	isFolder = true;
	info = service.getFolderProperties(sessionId,folderId);
} else if(fileIds!=null || folderIds!=null) {
	isMultiple = true;
	info = service.getMultipleItemProperties(sessionId,fileIds,folderIds);
}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title>Properties</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<link rel="stylesheet" type="text/css" href="style/filetypes.css" />

	<style type="text/css">
		html {
			margin: 0px;
			padding: 0px;
		}

		body {
			margin: 0;
			padding: 0;
			color: #3f3f3f;
		}

		body,td, input, select {
			font: 11px Tahoma;
		}

		a {
			text-decoration: none;
			color: #40608C;
		}

		a:hover {
			text-decoration: underline;
			color: #2D405B;
		}

		p {
			margin: 5px 0;
		}

		fieldset
		{
			border: solid 1px #B5B8C8;
			padding: 0 5px 10px 5px;
		}

		fieldset legend
		{
			margin-bottom: 2px;
			font: bold 11px verdana;
			color: #31508B;
		}
	</style> 
</head>
<body>

<table cellpadding="5px" width="100%">
	<tr>
		<td style="width:50px;">
			<img class="db-ft-medium db-ft-<%=isMultiple?"shared-docs":info.getIcon()%>-medium" src="../desktop/images/shared/blank.gif" style="border-width:0px;" />
		</td>
<%
if(isMultiple) {
%>
		<td><%=info.getFileCount()+" "+message.get("FileManager.properties.files")+", "+info.getFolderCount()+" "+message.get("FileManager.properties.folders")%></td>
<%
} else {
%>
		<td><%=info.getName()%></td>
<%
}
%>
	</tr>
	<tr>
		<td colspan="2"><hr/></td>
	</tr>
	<tr>
		<td><%=message.get("FileManager.properties.type")%>:</td>
<%
if(isMultiple) {
%>
		<td><%=message.get("FileManager.properties.multipleTypes")%></td>
<%	
} else {
%>
		<td><%=info.getType()%></td>
<%
}
%>
	</tr>
	<tr>
		<td><%=message.get("FileManager.properties.location")%>:</td>
		<td><%=info.getPath()%></td>
	</tr>
	<tr>
		<td><%=message.get("FileManager.properties.size")%>:</td>
		<td><%=info.getFormatSize()%> (<%=info.getSize()%> bytes)</td>
	</tr>
<%if(isFolder) {%> 
	<tr>
		<td><%=message.get("FileManager.properties.contains")%>:</td>
		<td><%=info.getFileCount()+" "+message.get("FileManager.properties.files")+", "+info.getFolderCount()+" "+message.get("FileManager.properties.folders")%></td>
	</tr> 
<%}%>
	<tr>
		<td colspan="2"><hr/></td>
	</tr>
<%if(isFolder || isFile) {%> 
	<tr>
		<td><%=message.get("FileManager.properties.created")%>:</td>
		<td><%=info.getDateCreated()%></td>
	</tr>
<%}%>
<%if(isFile) {%> 
	<tr>
		<td><%=message.get("FileManager.properties.modified")%>:</td>
		<td><%=info.getDateModified()%></td>
	</tr>
<%}%>
</table>

</body>
</html>